package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Attendance;
import cn.wolfcode.crm.domain.Salary;
import cn.wolfcode.crm.mapper.SalaryMapper;
import cn.wolfcode.crm.query.SalaryQueryObject;
import cn.wolfcode.crm.service.ISalaryService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class SalaryServiceImpl implements ISalaryService {


    @Autowired
    private SalaryMapper salaryMapper;


    public int deleteByPrimaryKey(Long id) {
        return salaryMapper.deleteByPrimaryKey(id);
    }

    public int insert(Salary record) {
        return salaryMapper.insert(record);
    }

    public Salary selectByPrimaryKey(Long id) {
        return salaryMapper.selectByPrimaryKey(id);
    }

    public List<Salary> selectAll() {
        return salaryMapper.selectAll();
    }

    public int updateByPrimaryKey(Salary record) {
        return salaryMapper.updateByPrimaryKey(record);
    }

    public PageResult query(SalaryQueryObject qo) {
        int count = salaryMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<Attendance> attendances = salaryMapper.queryList(qo);
        return new PageResult(count, attendances);
    }
}
